ToUTC Function

public function ToUTC(time1) result(time2)

Uses

Converts the value of the current DateTime object to Coordinated Universal Time (UTC).

Arguments

Type IntentOptional Attributes Name
type(DateTime), intent(in) :: time1

Return Value type(DateTime)


Variables

Type Visibility Attributes Name Initial
integer, public :: variation

Source Code

FUNCTION  ToUTC &
!
(time1) &
!
RESULT (time2)

USE Units, ONLY: &
!Imported parameters
hour, minute

IMPLICIT NONE

! Arguments with intent(in):
TYPE (DateTime), INTENT(IN) :: time1

! Local variables:
TYPE (DateTime) :: time2
INTEGER :: variation

!------------end of declaration------------------------------------------------

!reset time2
time2 = timeDefault

!calculate variation in seconds
variation = time1 % TZhour * hour + time1 % TZminute * minute

!Apply variation to convert to UTC
IF (time1 % TZsign == '+' ) THEN !subtract variation
  time2 = AddSeconds (time1, - variation)
ELSE IF (time1 % TZsign == '-' ) THEN !add variation
  time2 = AddSeconds (time1, variation)
END IF
time2 % TZhour   = 0
time2 % TZminute = 0
time2 % TZsign   = '+'
END FUNCTION ToUTC